﻿namespace LinkedTU.Data
{
    using System.Data.Entity;
    using Microsoft.AspNet.Identity.EntityFramework;
    using LinkedTU.Common.Constants;
    using LinkedTU.Data.Interfaces;
    using LinkedTU.Models;
    using LinkedTU.Data.Migrations;

    public class LinkedTuDbContext : IdentityDbContext<ApplicationUser>, ILinkedTuDbContext<ApplicationUser, IdentityRole>
    {
        public LinkedTuDbContext()
            : this(LinkedTUConstants.DbConnectionStringName)
        {
        }

        public LinkedTuDbContext(string connectionStringName)
            : base(connectionStringName)
        {
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<LinkedTuDbContext, DbContextMigrationConfiguration>());
        }

        public IDbSet<City> Cities { get; set; }

        public IDbSet<Country> Countries { get; set; }

        public IDbSet<JobPosition> JobPositions { get; set; }

        public IDbSet<Language> Languages { get; set; }

        public IDbSet<Certificate> Certificates { get; set; }

        public IDbSet<Comment> Comments { get; set; }

        public IDbSet<Company> Companies { get; set; }

        public IDbSet<Course> Courses { get; set; }

        public IDbSet<Endorsement> Endorsements { get; set; }

        public IDbSet<Group> Groups { get; set; }

        public IDbSet<GroupMembership> GroupsMemberships { get; set; }

        public IDbSet<GroupPost> GroupPosts { get; set; }

        public IDbSet<Job> Jobs { get; set; }

        public IDbSet<ProfileInfo> ProfilesInfos { get; set; }

        public IDbSet<Project> Projects { get; set; }

        public IDbSet<Recommendation> Recommendations { get; set; }

        public IDbSet<TakenCourse> TakenCourses { get; set; }

        public IDbSet<UserSkill> UsersSkills { get; set; }

        public IDbSet<CompanySize> CompanySizes { get; set; }

        public new IDbSet<TEntity> Set<TEntity>() where TEntity : class
        {
            return base.Set<TEntity>();
        }

        public static LinkedTuDbContext Create()
        {
            return new LinkedTuDbContext(LinkedTUConstants.DbConnectionStringName);
        }
    }
}
